//
//  LZXAppDelegate.m
//  Connotation
//
//  Created by LZXuan on 15-4-7.
//  Copyright (c) 2015年 LZXuan. All rights reserved.
//

#import "LZXAppDelegate.h"
#import "ConnotationViewController.h"

@implementation LZXAppDelegate
- (void)dealloc {
    self.window = nil;
    [super dealloc];
}
/*
 1.MVC设计 框架
    
    用tabBarController 管理子视图控制器
    搭建好 之后完善每个界面
 
 2.封装界面  
    每个界面
    2.1.封装 model
    2.2.封装 view
    2.3.下载数据 显示数据
    2.4 点赞 
 
  3 刷新和加载更多
 
 段子/趣图/美女 只有内容显示不一样
 趣图 有文字和图片  段子只有文字 美女只有 图片
 
 在设计model  和 cell 的时候 段子/趣图/美女 可以用一个类
 
 
 
 
 
 
 */

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    BOOL isnet=[LZXHelper reachability];
    if(!isnet){
        UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"没有网络，是否退出应用" message:@"⚠警告" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
        
        [alert show];
    }
    //创建一个自定义的tabBarController 管理子视图控制器
    ConnotationViewController *connotation = [[ConnotationViewController alloc] init];
    self.window.rootViewController = connotation;
    [connotation release];

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex ==1){
        
        
        [self exitApplication ];
        
    }
    
}

- (void)exitApplication {
    
    LZXAppDelegate *app = [UIApplication sharedApplication].delegate;
    UIWindow *window = app.window;
    
    [UIView animateWithDuration:1.0f animations:^{
        window.alpha = 0;
        window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
    } completion:^(BOOL finished) {
        exit(0);
    }];
    //exit(0);
    
}
- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
